/*
 * Copyright (c) 2011 Jean-Marc Perronne
 * Ensisa, 12 rue des Freres Lumieres, F-68093 Mulhouse cedex
 * All rights reserved.
 *
 * The copyright of this software is owned by Werner Randelshofer. 
 * You may not use, copy or modify this software, except in  
 * accordance with the license agreement you entered into with  
 * Jean-Marc Perronne. For details see accompanying license terms. 
 */

package fr.uha.ensisa.jmp.drone.input.progressive.connexion_3d;

import fr.uha.ensisa.jmp.connexion_3d.Mouse3D;
import fr.uha.ensisa.jmp.connexion_3d.Mouse3DException;
import fr.uha.ensisa.jmp.connexion_3d.Usage;

public class BasicMouseAdapter extends MouseAdapter
{
	private Usage usage;

	public BasicMouseAdapter()
	{}

	public BasicMouseAdapter(Mouse3D mouse)
	{
		super(mouse);
	}

	private Usage usage()
	{
		try
		{
			if (this.usage == null) this.usage = this.mouse().usage();
		}
		catch (Mouse3DException e)
		{
			e.printStackTrace();
		}
		return this.usage;
	}

	@Override
	protected float _adaptLeftRight(float value)
	{
		return  value / -this.usage().ryMax;
	}

	@Override
	protected float _adaptFrontBack(float value)
	{
		return value / this.usage().rxMax;
	}

	@Override
	protected float _adaptUpDown(float value)
	{

		return value / -this.usage().tzMax;
	}

	@Override
	protected float _adaptRotateLeftRight(float value)
	{
		return value / this.usage().rzMax;
	}
}
